package cac.common;

import java.io.*;
import java.util.HashMap;
import java.util.Properties;

public class LoadPropertiesFileUtil {
    private static String basePath = "F:\\test_curd\\test-curd-service\\src\\main\\resources\\prop.properties";
    private static String account = "";
    private static String password = "";
    private static String s = "";
    /**
     * 一、 使用java.util.Properties类的load(InputStream in)方法加载properties文件
     *
     * @return
     */
    public static String getPath() {
        try {
            InputStream in = new BufferedInputStream(new FileInputStream(
                    new File(basePath)));
            Properties prop = new Properties();
            prop.load(in);
            account = prop.getProperty("account");
            password = prop.getProperty("password");
            s = "账号："+account+"    密码："+password;
        } catch (FileNotFoundException e) {
            System.out.println("properties文件路径书写有误，请检查！");
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }
}
